/*
 * @Author: Aaron
 * @Date: 2022-05-05 16:26:05
 * @LastEditors: Aaron Huang
 * @LastEditTime: 2022-10-14 17:56:38
 * @Description: file content
 * @FilePath: \ias_ui\src\api\JDSupermarket\productsList.js
 * @Company: 沃尔玛
 */
import request from '@/utils/serve.js'
import { exportFile } from '@/api/JDSupermarket/exportFile.js'

const prefix = `${window.appConfig.jdsm}/item-mgmt-jdsm/`

const url = {
  list: `${prefix}jdsmGoodsInfo/queryPage`,
  listAll: `${prefix}jdsmGoodsInfo/queryPageAll`,
  delOffer: `${prefix}jdsmGoodsInfo/batchDelete`,
  productListExport: `${prefix}jdsmGoodsInfo/export/data`,
  productListExportAll: `${prefix}jdsmGoodsInfo/export/dataAll`,
  productOfferList: `${prefix}jdsmGoodsInfoImp/query/pageDataAndStatus`,
  verification: `${prefix}jdsmGoodsInfoImp/checkJdsmGoodsInfo`,
  uploadExcel: `${prefix}jdsmGoodsInfoImp/importJdsmGoodsInfo`,
  offerTemplanteExport: `${prefix}template/downloadJdsmGoodsInfoTemplate`,
  determineOffer: `${prefix}jdsmGoodsInfoImpBatch/confirm/importPrice`,
  productDetails: `${prefix}jdsmGoodsInfoByStore/queryPage`,
  delOfferbyStore: `${prefix}jdsmGoodsInfoByStore/batchDeleteByStore`,
  handleLog: `${prefix}jdsmGoodsInfoOprationLog/query/page`,
  queryOptions: `${prefix}`
}

// 获取列表
export const productList = (data) => {
  return request({
    method: 'post',
    url: url.list,
    data
  })
}

// 获取列表(全)
export const productListAll = (data) => {
  return request({
    method: 'post',
    url: url.listAll,
    data
  })
}

// 删除报价
export const delOfferApi = (data) => {
  return request({
    method: 'post',
    url: url.delOffer,
    data
  })
}

// 京商列表导出
export const productListExport = (data, name) => {
  return exportFile(url.productListExport, data, name)
}
// 京商列表导出(全量)
export const productListExportAll = (data, name) => {
  return exportFile(url.productListExportAll, data, name)
}

/**
 * 报价页面
 */

// 校验列表
export const productOfferList = (data) => {
  return request({
    method: 'post',
    url: url.productOfferList,
    data
  })
}

// 模板导出
export const offerTemplanteExport = () => {
  return exportFile(url.offerTemplanteExport, {}, '京超商品报价模板', { method: 'GET' })
}

// 导入
export const uploadExcel = (data) => {
  return request({
    method: 'put',
    url: url.uploadExcel,
    data
  })
}

// 发起报价校验
export const verification = (data) => {
  return request({
    method: 'post',
    url: url.verification,
    data
  })
}

// 确定报价
export const determineOffer = (data) => {
  return request({
    method: 'post',
    url: url.determineOffer,
    data
  })
}

/**
 * 商品报价详情
 */

// 获取区域以及门店
export const queryOptions = () => {
  return request({
    method: 'get',
    url: url.queryOptions
  })
}

// 获取列表
export const productDetails = (data) => {
  return request({
    method: 'post',
    url: url.productDetails,
    data
  })
}

// 删除报价
export const delOfferbyStore = (data) => {
  return request({
    method: 'post',
    url: url.delOfferbyStore,
    data
  })
}

// 查询是否有日志
export const handleLog = (data) => {
  return request({
    url: url.handleLog,
    method: 'POST',
    data
  })
}
